<?php 
	
	//========================================================================
	// Profit calculator
	//	
	echo "
		<div class='pageHeading'>" . Language::Get('Referral calculator') . "</div>

		<div class='lp1 pad15' style = 'background: none; '>
		  <div class='bpad15' id = 'calcContainer' style = ''>";
			
	echo '<form action = "#" method = "POST" id = "calcForm" onsubmit = "if (ValidateCalc()) { $(\'#btnCalc\').hide(); $(\'#loaderImage\').show(); '.jQuery::Post('/clients/calculate/', 'calcForm', 'AfterCalc').'} return false; ">';
	
	echo "<table cellspacing='0' cellpadding='0' border='0' style = 'margin-top: 15px; id='tablePrAccount'>"
		  ."<tr height='40px'>"
				."<td width = 200px nowrap='nowrap'>".Language::Get('Account type').":</td>"
				."<td class='inputType-1-left'></td>"
				."<td class='inputType-1-center'>";
	echo			XHTML::Select('account_type', $this->data['account_types'], false, false, array('style' => 'border: 0px; width: 140px;', 'id' => 'account_types'))
				."</td>"
				."<td class='inputType-1-right'/>"
			."</tr>";
	echo  "<tr height='40px'>"
				."<td width = 200px nowrap='nowrap'>".Language::Get('Followers account type').":</td>"
				."<td class='inputType-1-left'></td>"
				."<td class='inputType-1-center'>";
	echo			XHTML::Select('follower_account_type', $this->data['account_types'], false, false, array('style' => 'border: 0px; width: 140px;', 'id' => 'followers_account_type'))
				."</td>"
				."<td class='inputType-1-right'/>"
			."</tr>";
	echo  "<tr height='40px'>"
			."<td width = 200px nowrap='nowrap'>".Language::Get('Estimated number of followers').":</td>"
			."<td class='inputType-1-left'></td>"
			."<td class='inputType-1-center'>";
	echo		XHTML::InputText('followers_number', '0', array('style' => 'width: 100%', 'id' => 'Estimated_number_of_followers'))
			."</td>"
			."<td class='inputType-1-right'/>"
			."</tr>";
	echo  "<tr height='40px'>"
			."<td width = 200px nowrap='nowrap'>".Language::Get('Estimated number of referrals').":</td>"
			."<td class='inputType-1-left'></td>"
			."<td class='inputType-1-center'>";
	echo		XHTML::InputText('referrals_number', '0', array('style' => 'width: 100%', 'id' => 'Estimated_number_of_referrals'))
			."</td>"
			."<td class='inputType-1-right'/>"
			."</tr>";
	//button Calculate'
	echo "	<tr height='40px'>
			  <td>
				Total:
			  </td>
			  <td colspan=5>
				<span id='total' style='margin-left:5px'>0</span><span style = 'color: green;'>$</span>
			  </td>
			</tr>
			</table>
			
			<table cellspacing='0' cellpadding='0' border='0' style = 'margin-top: 15px;'>
			  <tr>
				<td class='btnType-5-left btnType-5-left-select'></td>
				<td class='btnType-5-center btnType-5-center-select' align='center' width=90px>
					<span id='btnCalc' class='btnType-5-txt cpointer' onclick=''>".Language::Get('Calculate')."</span>
				</td>
				<td>
				</td>
				<td class='btnType-5-right btnType-5-right-select'></td>
			  </tr>
			</table>
		</form>";
	echo "<div id='calcResultContainer' style='padding-top:1%;display:none'>";
		echo "If you open an account of&nbsp;"."<span id='span_account_types'>"."</span><span style = 'color: green; '>$</span>"
			 .", and add personally&nbsp;";
		echo "<span id='span_estimated_number_of_followers'></span>"
			 ."&nbsp;followers of&nbsp;";
		echo "<span id='span_followers_account_type'></span>"."<span style = 'color: green; '>$</span>"
			 ."&nbsp;account type, and you have already got&nbsp;";
		echo "<span id='span_estimated_number_of_referrals'></span>"
			 ."&nbsp;referrals, than you will make&nbsp;";
		echo "<span id='dataResultVal'></span><span style = 'color: green;'>$</span>";
	echo "</div>";
	//========================================================================
	// Deposit calculator
	//
	echo "<div id='siparater' style='padding-top:10px'>&nbsp</div>";
	echo "
		<div class='pageHeading'>" . Language::Get('Deposit calculator') . "</div>
		
		<div class='lp1 pad15' style = 'background: none; '>
		<div class='bpad15' id = 'calcContainer' style = ''>";
	echo '<form action = "#" method = "POST" id = "calcForm" onsubmit = " return false; ">';
	
	echo "<table cellspacing='0' cellpadding='0' border='0' style = 'margin-top: 15px; id='tablePrAccount'>";
	echo  "<tr height='40px'>"
		."<td width = 200px nowrap='nowrap'>".Language::Get('Type of deposit').":</td>"
		."<td class='inputType-1-left'></td>"
		."<td class='inputType-1-center'>";
	echo		XHTML::Select('deposit_type', $this->data['depositTypes'], false, false, array('style' => 'border: 0px; width: 140px;', 'id' => 'TypeOfDeposit'))
		."</td>"
		."<td class='inputType-1-right'/>"
		."</tr>";
	echo  "<tr height='40px'>"
		."<td width = 200px nowrap='nowrap'>".Language::Get('Amount to deposit').":</td>"
		."<td class='inputType-1-left'></td>"
		."<td class='inputType-1-center'>";
	echo		XHTML::InputText('deposit_type', '0', array('style' => 'width: 100%', 'id' => 'AmountToDeposit'))
		."</td>"
		."<td class='inputType-1-right'/>"
		."</tr>";
	//button Calculate'
	echo "<tr height='40px'>
			<td>
				Total:
			</td>
			<td colspan=5>
				<span id='depositTotal' style='margin-left:5px'>0</span></span><span style = 'color: green;'>$</span>
			</td>
		  </tr>
		</table>
	
		<table cellspacing='0' cellpadding='0' border='0' style = 'margin-top: 15px;'>
		  <tr>
			<td class='btnType-5-left btnType-5-left-select'></td>
		 	<td class='btnType-5-center btnType-5-center-select' align='center' width=200px>
				<span id='btnCalc' class='btnType-5-txt cpointer' onclick='AfterDepositCalc()'>".Language::Get('Calculate estimated profit')."</span>
			</td>
			<td class='btnType-5-right btnType-5-right-select'></td>
		  </tr>
		</table>
		<div id='test'></div>
	  </form>";
	echo "<div id='calcDepositResultContainer' style='padding-top:1%;display:none'>";
	echo "If you make a &nbsp;"
		 ."<span id='span_TypeOfDeposit'></span>";
	echo " deposit of&nbsp;"
		 ."<span id='span_AmountToDeposit'></span>"
		 ."<span style = 'color: green; '>$</span>";
	echo "&nbsp;you may earn&nbsp;"
		 ."<span id='span_you_will_get'>"
		 ."</span><span style = 'color: green;'>$</span>";
	echo "</div>";
?>

<script type="text/javascript">

	$('#btnCalc').dqButton({type:5, action:"$('#calcForm').submit();", clickType:'js', live: false});
	$('#calcContainer .btnType-5-left').addClass('btnType-5-left-select');	
	$('#calcContainer .btnType-5-center').addClass('btnType-5-center-select');	
	$('#calcContainer .btnType-5-right').addClass('btnType-5-right-select');	
	$('#calcContainer .dq-input-text').dqInput();

	//validates calc form
	function ValidateCalc()
	{
//		if (($('[name=support_question]').val() == '') || ($('[name=support_details]').val() == '') || ($('[name=support_name]').val() == '') || 
//			($('[name=support_email]').val() == ''))
//		{
//			alert('Please, fill all the required fields');
//			return false;
//		}
//		else
//		{
			return true;
//		}
	}

	//after calc
	function AfterCalc( data )
	{
		//show result string
		$('#calcResultContainer').hide();
		$('#calcResultContainer').fadeIn('100');
	    //variables for profit result string
		var account_types = parseInt( $('#account_types option:selected').text() );
		var followers_account_type = parseInt( $('#followers_account_type option:selected').text() );
		var Estimated_number_of_followers = $('#Estimated_number_of_followers').val();
		var Estimated_number_of_referrals = $('#Estimated_number_of_referrals').val();
		$("#span_account_types").html(account_types);
		$("#span_estimated_number_of_followers").html(Estimated_number_of_followers);
		$("#span_followers_account_type").html(followers_account_type); 
		$("#span_estimated_number_of_referrals").html(Estimated_number_of_referrals); 
		$("#dataResultVal").html(data);
		//alert(data)
	    $('#total').text(data);
		$('#loaderImage').hide();
		$('#btnCalc').show();
	}

	function AfterDepositCalc()
	{

		//show result string
		$('#calcDepositResultContainer').hide();
		$('#calcDepositResultContainer').fadeIn('100');
		//variables for deposit result string
		var TypeOfDeposit = $('#TypeOfDeposit option:selected').text();
		var AmountToDeposit = $('#AmountToDeposit').val();
		$('#span_TypeOfDeposit').html(TypeOfDeposit);
		$('#span_AmountToDeposit').html(AmountToDeposit);
		var deposits_percent = new Array();
		var deposits_period = new Array();			
		
		<?php 
		
			foreach ($this->data['depositTypes'] as $key => $value)
			{
				
				echo "deposits_period[" .$value['id']. "] = " . $value['period'] . ";";
				echo "deposits_percent[" .$value['id']. "] = ". $value['percent'] . ";";
				
			}
		?>	
		
		var depositPeriod = $("#TypeOfDeposit option:selected").text();
		var depositSum = $("#AmountToDeposit").val();
		var id = $("#TypeOfDeposit option:selected").val();
		if (isNaN(parseInt(depositSum)) || parseInt(depositSum) < 1)
		{
			alert('Wrong amount!');
			return false;
		}   

		var sum = parseInt(depositSum);
		var precent = parseInt(deposits_percent[ id ]);
		
		for(var i = 1; i <= parseInt(depositPeriod); i++)
		{
			sum += (sum * precent) / 100;
		}
		sum = Math.floor(sum);
		$('#span_you_will_get').html(sum);
		$("#depositTotal").html(sum);
	}
</script>